#include "DynamicPropertyList.h"

_BEGIN_BOARDGAME_NAMESPACE_


DynamicPropertyList::DynamicPropertyList()
{
}


const PropertyMap & DynamicPropertyList::GetProperties() const
{
	return m_properties;
}


void DynamicPropertyList::AddProperty( const tstring & name, DynamicPropertyType type )
{
	this->CheckNameUniqueness( name );
	m_properties.insert( make_pair( name, DynamicPropertyValue( type ) ) );
}


const DynamicPropertyValue & DynamicPropertyList::GetValue( const tstring & name ) const
{
	PropertyMap::const_iterator it = m_properties.find( name );
	if( it == m_properties.end() )
	{
		throw invalid_argument( "Property with specific name does not existed." );
	}

	return it->second;
}


void DynamicPropertyList::SetValue( const tstring & name, bool value )
{
	this->SetData( name, value );
}


void DynamicPropertyList::SetValue( const tstring & name, int value )
{
	this->SetData( name, value );
}


void DynamicPropertyList::SetValue( const tstring & name, float value )
{
	this->SetData( name, value );
}


void DynamicPropertyList::SetValue( const tstring & name, const tchar * value )
{
	this->SetData( name, value );
}


void DynamicPropertyList::SetValue( const tstring & name, const tstring & value )
{
	this->SetData( name, value );
}


void DynamicPropertyList::CheckNameUniqueness( const tstring & name ) const
{
	PropertyMap::const_iterator it = m_properties.find( name );
	if( it != m_properties.end() )
	{
		throw invalid_argument( "Duplicate property name." );
	}
}


_END_BOARDGAME_NAMESPACE_